package com.wei.concurrent;

/**
 * 显式锁接口
 *
 * @author :sunwei
 * @description:
 * @date create in 22:03  2021/6/16
 */
public interface ExplicitLock {
    
    class TimeOutException extends Exception {
        public TimeOutException(String message) {
            super(message);
        }
    }
    
    /**
     * <p>加锁</p>
     * @version 0.1.0
     * @return void
     * @author SunWei
     * @date 2021/6/16 22:10
     * @since 0.1.0
    */
    void lock() throws InterruptedException;
    
    /**
     * <p>在一段时间内若无法获取到锁,则退出获取</p>
     * @param mills mills
     * @version 0.1.0
     * @return void
     * @author SunWei
     * @date 2021/6/16 22:10
     * @since 0.1.0
    */
    void lock(long mills) throws InterruptedException,TimeOutException;
    
    /**
     * <p>释放锁</p>
     * @version 0.1.0
     * @return void
     * @author SunWei
     * @date 2021/6/16 22:10
     * @since 0.1.0
    */
    void unlock();
    
}
